<%-------------------------------------------------------------------
 * 页面名称：innerPay_1.jsp
 * 功能描述：网上付款－填写付款信息
 * Action  : innerPay
 *
 *-------------------------------------------------------------------
--%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%
	String path = request.getContextPath();
%>
<script type='text/javascript' src='<%=path%>/js/ufront.js'></script>
<script type='text/javascript'
	src='<%=path%>/dwr/interface/accountTemplate.js'></script>
<script type='text/javascript'
	src='<%=path%>/js/vnv/commonForCnAmount.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/tomoney.js'></script>
<script language="JavaScript" type="text/JavaScript">
function submitProcess(){
var objSelect = document.getElementsByName("debitSubAccountId")[0].value;
	accountTemplate.authentication(objSelect,showResult);
}
function showResult(data)
{
	if(data=="true")
	{
		alert("您还未进行实名认证，不能使用该交易！");
		return;
	}else
	{
	var amount=document.getElementsByName("amount")[0].value;
		accountTemplate.confirmToRuleByInneryPay(amount,show);
	}
}
function show(data)
	{
		if(document.InnerPayForm.remark.value.length>85){
		alert("备注长度不能大于85！");
		return;
	}
	if("72"==data){
	document.getElementsByName("amount")[0].focus();
	   alert("违反单笔付款限额");
	   return;
	}
	if("73"==data){
	document.getElementsByName("amount")[0].focus();
	   alert("违反每日付款限额");
	   return;
	}
	if("74"==data){
	 document.getElementsByName("amount")[0].focus();
	   alert("违反每月付款限额");
	   return;
	}
		if(checkNecessaryInput(document.InnerPayForm)){
		document.InnerPayForm.submit();
	}
	}
function page_onchangeSubAccount(){
		var objSelect = document.getElementsByName("debitSubAccountId")[0];
		var strSelectedValue = "";
		var length = objSelect.options.length - 1;    
		for(var i = length; i >= 0; i--){    
			if(objSelect[i].selected == true){    
				strSelectedValue = objSelect.options[i].value;
			}    
		}
		if(strSelectedValue != "" && strSelectedValue != null && strSelectedValue > 0) {
			accountTemplate.accountMoney(strSelectedValue, setBalance);
		}
		else {
			setBalance(0);
		}
	}
function setBalance(money) {
	getObj('subaccountbalanceid').innerHTML = money + '元';
}
function updatePrompt(data) {
   if (data==2){
    	alert("该子账户没有足够资金！");
    	return;
   }
}
function initAssured(){
	var assuredObjects = document.getElementsByName("assured");
	if(assuredObjects.length>1){
		for(var i=0;i<assuredObjects.length;i++){
			if(assuredObjects[i].checked){
			var ifChecked = assuredObjects[i].value;
			
				selectTradeType(ifChecked);
				
				break;
			}
		}
	}else{
		selectTradeType(assuredObjects.value);
	}
}
function validateCreditAccount(v) {
	v = v.replace(/ /g,"");
	if (v=="") {
		document.InnerPayForm.credit.value="";
		document.getElementsByName("creditName")[0].value = "";
		return;
	} else {
		accountTemplate.validateAccount(v,check);
	}
}
function check(obj){
	if (obj == '-1'){
		alert('该账户不存在!');
		document.InnerPayForm.credit.value="";
		document.getElementsByName("creditName")[0].value = "";
		return;
	} else {
		getAccountNameByName(obj);
	}
}
function getAccountNameByName(value) {
	if(value == null) value = "";
	document.getElementsByName("creditName")[0].value = value;
}
function emailSelect(){
 	agiledata.getUserInternal(emailPopup);
}
function emailPopup(data) {
  	if(data) {
	 	openLayer("<%=path%>/page/common/selectEmail.do");
	} else {
		location.href="<%=path%>/page/util/session_invalid.jsp";
	}      
}
function amountSelect(){
 	agiledata.getUserInternal(amountPopup);
}
function amountPopup(data) {
  	if(data) {
	 	openLayer("<%=path%>/page/common/simpleCalculator.jsp",400,200,false);
	} else {
		location.href="<%=path%>/page/util/session_invalid.jsp";
	}      
}
function selectTradeType(assured) {
	
    if(assured=='true'){
   
    	document.getElementById("assuredInfo").style.display = "";
    	document.getElementById("unassuredInfo").style.display = "none";
    }else{
    	
    	document.getElementById("assuredInfo").style.display = "none";
    	document.getElementById("unassuredInfo").style.display = "";
    }
}
function kd(){
	var ss=getObj("amount").value;
	ss = ss.replace(/ /g,"");
	if (ss=="") {
		getObj("upperAmount").value="";
		return;
	}
	
	var sDispMsg = getChineseCurrencyString(ss);
	if(sDispMsg==-1) sDispMsg="错误的金额!";
	if(sDispMsg==-2) sDispMsg="太长的金额!";
	getObj("upperAmount").value=sDispMsg;
}
function numToChinese(num){
	var chinese = Chinese(num);
	document.InnerPayForm.chinese.innerText= "大写："+chinese+"元";
}
	function amountBlur(objAmount) {
		// 金额失去焦点方法
		if (checkDecimalInput(objAmount,0) && document.all.debitSubAccountId.value!='') {
			accountTemplate.compareAccountMoney(document.all.debitSubAccountId.value,objAmount.value, updatePrompt);
		} 
		tomoney('InnerPayForm','amount','hideTransAmt');
		kd();
	}
</script>
<div id="main">
	<div class="content_right">
		<div style="width: 745px; margin-left: 10px;">
			<div class="titleinfo">
				网上付款
			</div>
			<div class="edit_pass">
				<html:form action="innerPay" method="post">
					<html:hidden property="step" />
					<table width="100%" border="0" align="center" cellpadding="5"
						cellspacing="1">
						<tr>
							<td width="23%" align="right" height="35px;">
								付款子账户：
							</td>
							<td width="77%" height="35px;">
								<html:select property="debitSubAccountId"
									onchange="page_onchangeSubAccount();">
									<html:options collection="subAccounts" property="id"
										labelProperty="accountName" />
								</html:select>
							</td>
						</tr>
						<tr>
							<td height="21" align="right" height="35px;">
								当前余额：
							</td>
							<td height="35px;">
								<span class="orangefont14b"><div id="subaccountbalanceid"></div>
								</span>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								<span class="orang12b">*</span> 收款方账户：
							</td>
							<td height="35px;">
								<logic:notPresent name="creditAccount">
									<html:text property="credit" size="50" styleClass="inputStyle"
										alt="收款方账户" onblur="validateCreditAccount(this.value);" />
			&nbsp;&nbsp;<img src="<%=path%>/images/icon_email.gif" width="13"
										height="10" border="0" style="cursor: hand"
										  />
										<!-- title="请点击此按钮，选择交易对象" onclick="emailSelect();" -->
									<span class="font_gray">可以输入收款方的Email或者手机</span>
								</logic:notPresent>
								<logic:present name="creditAccount">
									<logic:notEmpty name="creditAccount" property="email">
										<input type="hidden" name="credit"
											value="<bean:write name="creditAccount" property="email"/>" />
										<bean:write name="creditAccount" property="email" />
									</logic:notEmpty>
									<logic:empty name="creditAccount" property="email">
										<input type="hidden" name="credit"
											value="<bean:write name="creditAccount" property="mobile"/>" />
										<bean:write name="creditAccount" property="mobile" />
									</logic:empty>
								</logic:present>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								收款方名称：
							</td>
							<td height="35px;">
								<input name="creditName" type="text" class="inputStyleNoborder"
									size="50" readOnly
									<logic:present name="creditAccount">value="<bean:write name="creditAccount" property="name"/>"</logic:present>>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								<span class="orang12b">*</span> 付款金额：
							</td>
							<td height="35px;">
								<logic:notPresent name="amount">
									<html:text property="amount" alt="付款金额" size="50"
										styleClass="inputStyle" onblur="amountBlur(this);"
										onkeyup="kd();" onchange="kd();" />
				&nbsp;<span class="fontgraydrop14">元</span>
			&nbsp;&nbsp;<img src="<%=path%>/images/money.gif" width="17"
										height="17" border="0" style="cursor: hand"
										title="请使用计算器，计算付款金额" onclick="amountSelect();" />
									<INPUT type="hidden" NAME="hideTransAmt" value="">
								</logic:notPresent>
								<logic:present name="amount">
									<input type="hidden" name="amount"
										value="<bean:write name="amount"/>" />
									<bean:write name="amount" />
								</logic:present>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								付款金额大写：
							</td>
							<td height="35px;">
								<input type="text" name="upperAmount" size="50"
									class="inputStyleNoborder" readonly />
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								手续费收取方法：
							</td>
							<td class="fontgraydrop14" height="35px;">
								<bean:write name="feeRatioMode" />
							</td>
						</tr>
						<tr>
							<td align="right" valign="top" height="35px;">
								交易模式：
							</td>
							<td valign="top" class="fontgraydrop14" height="35px;">
								<logic:notPresent name="assuredPay">
									<html:radio property="assured" style="border:0" value="true"
										onclick="selectTradeType('true');" /> 担保交易&nbsp;&nbsp;&nbsp;&nbsp;
				<html:radio property="assured" style="border:0" value="false"
										onclick="selectTradeType('false');" /> 非担保交易
			  </logic:notPresent>
								<logic:present name="assuredPay">
									<input type="hidden" name="assured"
										value="<bean:write name="assuredPay"/>" />
									<logic:equal name="assuredPay" value="true">担保交易</logic:equal>
									<logic:equal name="assuredPay" value="false">非担保交易</logic:equal>
								</logic:present>
								<br />
								<table width="100%" border="0" align="center" cellpadding="7"
									cellspacing="1" bgcolor="#f9e277" style="margin: 10px 0;">
									<tr>
										<td bgcolor="#fffdf5">
											<div id="assuredInfo" style="display: none;">
												<table width="100%" border="0" cellpadding="3"
													cellspacing="0">
													<tr>
														<td width="3%" height="25" valign="top"
															style="border-bottom: 1px solid #ccc;"></td>
														<td width="97%" align="left" class="red12b"
															style="border-bottom: 1px solid #ccc;">
															担保交易流程如下
														</td>
													</tr>
													<tr>
														<td height="25" valign="top">
															&nbsp;
														</td>
														<td align="left" class="text9green">
															1) 买家确认付款到支付网站；
														</td>
													</tr>
													<tr>
														<td height="25" valign="top">
															&nbsp;
														</td>
														<td align="left" class="text9green">
															2) 支付网站通知卖家发货；
														</td>
													</tr>
													<tr>
														<td height="25" valign="top">
															&nbsp;
														</td>
														<td align="left" class="text9green">
															3) 卖家发货；
														</td>
													</tr>
													<tr>
														<td height="25" valign="top">
															&nbsp;
														</td>
														<td align="left" class="text9green">
															4) 买家收到货物满意后通知支付网站付款到卖家。
														</td>
													</tr>
													<tr>
														<td valign="top">
															&nbsp;
														</td>
														<td align="left" class="font_gray">
															如果您在其他购物网站上看中某件商品，可与卖家取得联系，请他注册成为支付网站用户后向您发起“账户间收款”交易。
														</td>
													</tr>
												</table>
											</div>
											<div id="unassuredInfo" style="display: none;">
												<table width="100%" border="0" cellpadding="3"
													cellspacing="0">
													<tr>
														<td width="3%" height="25" valign="top"
															style="border-bottom: 1px solid #ccc;"></td>
														<td width="97%" align="left" class="red12b"
															style="border-bottom: 1px solid #ccc;">
															特别提醒
														</td>
													</tr>
													<tr>
														<td height="25" valign="top">
															&nbsp;
														</td>
														<td align="left" class="font_gray">
															<span class="lan">此笔款项将直接进入对方账户，请确认您确实要支付此笔款项。</span>
														</td>
													</tr>
													<tr>
														<td height="25" valign="top">
															&nbsp;
														</td>
														<td align="left" class="font_gray">
															<span>支付网站不对您的此笔款项进行担保，也不对此承担任何责任。</span>
														</td>
													</tr>
												</table>
											</div>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								商品信息：
							</td>
							<td height="35px;">
								<logic:notPresent name="commodity">
									<html:text property="commodity" size="50" maxlength="85"
										styleClass="inputStyle" />
								</logic:notPresent>
								<logic:present name="commodity">
									<input type="hidden" name="commodity"
										value="<bean:write name="commodity"/>" />
									<bean:write name="commodity" />
								</logic:present>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								<span class="orang12b">*</span> 资金用途：
							</td>
							<td height="35px;">
								<html:text property="purpose" alt="资金用途" value="现金" size="50"
									maxlength="85" styleClass="inputStyle" onblur="killSpace(this)" />
								<span class="font_gray">(最长85个字符) </span>
							</td>
						</tr>
						<tr>
							<td align="right" height="35px;">
								备注：
							</td>
							<td height="35px;">
								<logic:notPresent name="remark">
									<html:textarea property="remark" rows="5" cols="35" />
									<span class="font_gray">(最长85个字符) </span>
								</logic:notPresent>
								<logic:present name="remark">
									<input type="hidden" name="remark"
										value="<bean:write name="remark"/>" />
									<bean:write name="remark" />
								</logic:present>
							</td>
						</tr>
						<!-- 错误信息提示 -->
						<logic:present name="org.apache.struts.action.ERROR">
							<tr>
								<td colspan="2" height="25" align="center">
									&nbsp;
									<font color="#FF0000"><html:errors /> </font>
								</td>
							</tr>
						</logic:present>
						<tr>
							<td height="55" align="right">
								&nbsp;
							</td>
							<td>
								<input name="next" type="button" class="button_style"
									onclick="submitProcess();" value="下一步" />
							</td>
						</tr>
					</table>
				</html:form>
				<table width="100%" border="0" align="center" cellpadding="7"
					cellspacing="1" bgcolor="#f9e277" style="margin: 10px 0;">
					<tr>
						<td bgcolor="#fffdf5">
							<table width="100%" border="0" cellpadding="3" cellspacing="0">
								<tr>
									<td width="3%" height="25" valign="top"
										style="border-bottom: 1px solid #ccc;"></td>
									<td width="97%" align="left" class="red12b"
										style="border-bottom: 1px solid #ccc;">
										特别提醒
									</td>
								</tr>
								<tr>
									<td valign="top">
										&nbsp;
									</td>
									<td align="left" class="font_gray">

										<span class="lan">您可以使用您的支付账户通过Email或手机进行付账！</span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="<%=path%>/js/layer.js"></script>
<script language="javaScript">
function closeLayer(returnValue, type){
	hideLayer();
	if(type=="email"){
		document.InnerPayForm.credit.value=returnValue[1];
		document.InnerPayForm.credit.focus();
	}else if(type=="amount"){
		document.InnerPayForm.amount.value=returnValue;
		document.InnerPayForm.amount.focus();
		kd();
	}
}

<logic:notPresent name="creditAccount">
//显示预先设置的收款方名称
validateCreditAccount(document.InnerPayForm.credit.value);
</logic:notPresent>

//显示预先设置的金额大写
kd();

//显示预先设置的交易模式
initAssured();
//显示预先设置的子账户余额
var objSelect = document.getElementsByName("debitSubAccountId")[0];
var strSelectedValue = "";
var length = objSelect.options.length - 1;    
for(var i = length; i >= 0; i--){    
	if(objSelect[i].selected == true){    
		strSelectedValue = objSelect.options[i].value;
	}    
}
if(strSelectedValue != "" && strSelectedValue != null && strSelectedValue > 0) {
	accountTemplate.accountMoney(strSelectedValue, setBalance);
}else {
	setBalance(0);
}
</script>
